{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "4655ed41",
   "metadata": {},
   "outputs": [],
   "source": [
    "import re\n",
    "import requests\n",
    "#使用requests\n",
    "# headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36'}\n",
    "# r = requests.get(url=\"https://www.baidu.com\",headers=headers)\n",
    "#打印获取到的内容\n",
    "# print(r.text)\n",
    "str1 = '<tr><td class=\"\"><a class=\"zbExp\" exp=\"参照《国家统计局关于修订<三次产业划分规定（2012）>的通知》（国统设管函〔2018〕74号）中三次产业划分标准，在我国境内从事第一产业社会经济活动的法人单位数量。\" href=\"javascript:void(0);\"><img src=\"images/icon-1.png\"></a>第一产业法人单位数(个)</td><td align=\"right\" class=\"\">1915236</td><td align=\"right\" class=\"\">1827421</td><td align=\"right\" class=\"\">1642773</td><td align=\"right\" class=\"\">1224</td><td align=\"right\" class=\"\">1670774</td><td align=\"right\" class=\"\">1262764</td><td align=\"right\" class=\"\">1005230</td><td align=\"right\" class=\"\">773414</td><td align=\"right\" class=\"\">1815</td><td align=\"right\" class=\"\">440853</td></tr>'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "aa06fc78",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<td align=\"right\" class=\"\">1915236</td>\n"
     ]
    }
   ],
   "source": [
    "#str1 = '<td class=\"\"><a class=\"zbExp\" exp=\"参照《国家统计局关于修订<三次产业划分规定（2012）>的通知》（国统设管函〔2018〕74号）中三次产业划分标准，在我国境内从事第一产业社会经济活动的法人单位数量。\" href=\"javascript:void(0);\"><img src=\"images/icon-1.png\"></a>第一产业法人单位数(个)</td>'\n",
    "res = re.search('<td align=\"right\" class=\"\">(.+?)</td>',str1)\n",
    "# re.findall('\\W',res[0])\n",
    "print(res.group())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4490ec83",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
